/*
 * @Author: 江舟 jijiangzhou@recycloud.cn
 * @Date: 2024-05-14 17:06:53
 * @LastEditors: 江舟 jijiangzhou@recycloud.cn
 * @LastEditTime: 2024-05-16 14:57:43
 * @FilePath: \vite-project\src\components\common\AuthPerm.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import useUserStore from 'store/user';
import { ReactNode } from 'react';

const AuthPerm: React.FC<{
    children: ReactNode;
    permission?: string;
}> = (props) => {
    const { actionPerms } = useUserStore();

    if (!props.permission) {
        return props.children;
    }

    if (actionPerms?.includes(props.permission)) {
        return props.children;
    }

    return <></>;
};

export default AuthPerm;
